package com.lavida.project.companymanager.controller;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lavida.framework.web.controller.BaseController;
import com.lavida.framework.web.page.TableDataInfo;
import com.lavida.project.companymanager.domain.EmpInformation;
import com.lavida.project.companymanager.service.EmpInformationService;

/**
 * 核算新工资
 * 
 */
@Controller
@RequestMapping("/companymanager/empinformation")
public class EmpInformationController extends BaseController
{
    private String prefix = "companymanager/empinformation";

    @Autowired
    private EmpInformationService empInformationService;

    @RequiresPermissions("companymanager:empinformation:view")
    @GetMapping()
    public String empInformation()
    {
        return prefix + "/empinformation";
    }
    
    @RequiresPermissions("companymanager:empinformation:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    @RequiresPermissions("companymanager:empinformation:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(EmpInformation empInformation)
    {
        startPage();
        List<EmpInformation> list = empInformationService.selectEmpInfoList(empInformation);
        return getDataTable(list);
    }


    /**
     * 修改保存
     */
   /* @RequiresPermissions("wage:newwageaccount:edit")
    @Log(title = "用户管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(@Validated User user)
    {
        userService.checkUserAllowed(user);
        if (UserConstants.USER_PHONE_NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
        {
            return error("修改用户'" + user.getLoginName() + "'失败，手机号码已存在");
        }
        else if (UserConstants.USER_EMAIL_NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
        {
            return error("修改用户'" + user.getLoginName() + "'失败，邮箱账号已存在");
        } 
        //该部门已经有部门领导，不是本人，不允许修改
        String deptLeader = userMapper.selectDeptLeaderId("deptLeader", user.getDeptId());
        if(Arrays.asList(user.getRoleIds()).contains(100L) && StringUtils.isNotBlank(deptLeader) && !user.getLoginName().equals(deptLeader)) {
        	return error("修改用户'" + user.getLoginName() + "'失败，该部门已经有一位用户的角色为部门领导");
        }
        return toAjax(userService.updateUser(user));
    }*/

  /*  @RequiresPermissions("wage:newwageaccount:remove")
    @Log(title = "用户管理", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        try
        {
            return toAjax(userService.deleteUserByIds(ids));
        }
        catch (Exception e)
        {
            return error(e.getMessage());
        }
    }*/

   
    
}